function forgetPassword(url) {
	$('div#forgetError, div#forgetNoUser, div#forgetSuccess').hide();
	
	$.get(url,
		  {'email': $('input[name="forgetEmail"]').val()},
		  forgetPasswordResponse,
		  'json');	
}

function forgetPasswordResponse(data) {
	
	if ( data.status == 'error' ) {
		$('div#forgetError').show();
	}
	
	if ( data.status == 'noUser' ) {
		$('div#forgetNoUser').show();
	}
	
	if ( data.status == 'ok' ) {
		$('div#forgetSuccess').show();
		$('input[name="forgetEmail"]').val('');
	}
}

function register(url) {
	$('div#registerSuccess, div#registerError').hide();
	$('div.control-group').removeClass('error');
	$('span', 'div.control-group').hide();
	
	$.get(url,
		  {'email': $('input[name="registerEmail"]').val(), 
		   'nick': $('input[name="registerUsername"]').val(),
		   'type': $('input[name="registerType"]').val()},
		  registerResponse,
		  'json');	
}

function registerResponse(data) {
	
	if ( data.status == 'noAdmin' ) {
		$('div#registerError').show();
	}
	
	if ( data.status == 'duplicateEmail' ) {
		var container = $('input[name="registerEmail"]').closest('div.control-group');
		container.addClass('error');
		$('.hide', container).show();
	}
	
	if ( data.status == 'duplicateNick' ) {
		var container = $('input[name="registerUsername"]').closest('div.control-group');
		container.addClass('error');
		$('.hide', container).show();		
	}
	
	if ( data.status == 'ok' ) {
		$('div#registerSuccess').show();
		$('input[name="registerUsername"], input[name="registerEmail"]').val('');
	}
}